package web.servlet.response;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author: 18148
 * @Date: 2020-05-20 10:19:29
 */
@WebServlet("/hW2_4")
public class HW2_4 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       /*五秒钟后自动跳转：设置响应头
       * 点击链接：跳转
       *  */
        resp.setContentType("text/html;charset=utf-8");
        //设置编码
        PrintWriter pw = resp.getWriter();
        //字符输出流
        pw.write("支付成功 5秒后 系统将自动跳转到....页面<a href=http://localhost:8080/web/homework/story.html>若未自动跳转,请点击这里</a>");
        resp.setHeader("ReFresh","5;URL=http://localhost:8080/web/homework/story.html");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
